import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Specification

class GPluginTest extends Specification {
    @Rule
    final TemporaryFolder projectFolder = new TemporaryFolder()
    private File buildFile


    def setup() {
        println 'hello'
    }

    def "test01"() {

        int age = 1;

        when:

        age > 10

        then:
        println 'then:' + age

        cleanup:

        println 'test cleanup'
    }





    def "Poms generated by the maven plugin are customized"() {
        given: 'A project with the maven plugin applied and some dependency management'

        buildFile << """
            buildscript {
                dependencies {
                    classpath files('${new File("build/classes/main").getAbsolutePath()}',
                            '${new File("build/resources/main").getAbsolutePath()}',
                            '${new File("build/libs/maven-repack-3.0.4.jar").getAbsolutePath()}')
                }
            }

            apply plugin: 'io.spring.dependency-management'
            apply plugin: 'java'
            apply plugin: 'maven'

            repositories {
                mavenCentral()
            }

            dependencyManagement {
                imports {
                    mavenBom 'org.springframework.boot:spring-boot-dependencies:1.4.2.RELEASE'
                }
            }
        """

        when: 'The install task is run'

        GradleRunner.create().withProjectDir(projectFolder.root).withArguments("install").build()

        then: 'The generated pom contains dependency management'

        new File(projectFolder.root, "build/poms/pom-default.xml").text.contains("<dependencyManagement>")

    }






}
